#include <stdio.h>

enum LightState
{
  RED,
  YELLOW,
  GREEN
};

// 写一个delay函数，并用for循环模拟红绿灯循环闪烁
void delay(int seconds)
{
  for (int i = 0; i < seconds; i++)
  {
    for (volatile int j = 0; j < 1000000; j++)
      ;
  }
}
int main()
{
  enum LightState currentLight = RED;
  int i, j;
  int seconds = 1000;

  while (1)
  {
    switch (currentLight)
    {
    case RED:
      printf("RED\n");
      currentLight = GREEN;
      break;
    case GREEN:
      printf("GREEN\n");
      currentLight = YELLOW;
      break;
    case YELLOW:
      printf("YELLOW\n");
      currentLight = RED;
      break;
    default:
      printf("Invalid light state\n");
    }
    delay(seconds);
  }

  return 0;
}